package cn.iocoder.yudao.module.promotion.coupon.job;

import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
import cn.iocoder.yudao.module.promotion.coupon.service.CouponTemplateService;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

/**
 * 固定日期领取的优惠券模板开始及结束 Job
 *
 * @author owen
 */
@Component
public class CouponTemplateValidJob implements JobHandler {

    @Resource
    @Lazy // 延迟加载，避免循环依赖
    private CouponTemplateService couponTemplateService;

    @Override
    @TenantJob
    public String execute(String param) {
        int startCount = couponTemplateService.startCouponTemplate();
        int endCount = couponTemplateService.endCouponTemplate();
        return StrUtil.format("开始优惠券 {} 个，结束优惠券 {} 个", startCount, endCount);
    }

}
